package com.kye.express.business.jpush;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.kye.express.business.splash.SplashActivity;
import com.kye.model.bean.jpush.PushSplashModel;

public class JpushNotificationClickReceiver extends BroadcastReceiver {
    public static final String ARG_DATA = "pushSplashBean";

    @Override
    public void onReceive(Context context, Intent intent) {
        PushSplashModel pushSplashBean = (PushSplashModel) intent.getSerializableExtra(ARG_DATA);
        if (pushSplashBean != null) {
            if (JpushNotificationUtils.checkApkExist(context)) {
                JPushResponseParseHelper.getInstance().init(context, pushSplashBean).startParseJPushResponse();
            } else {
                JpushNotificationUtils.savePushSplashBean(pushSplashBean);
                Intent actIntent = new Intent(context, SplashActivity.class);
                actIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                context.startActivity(actIntent);
            }
        }
    }

}